package com.neuedu.javase.oo.myabstract.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

/***
 * 项目名称:  MyJavaSE 
 * 包：  com.neuedu.javase.oo.myabstract.ui 
 * date:   2025/10/24   14:34  
 * 描述:  
 *  @author : 张金山
 *  作者博客:   https://blog.fulfill.com.cn
 */
public class MyUI  extends JFrame  implements  MouseListener , KeyListener  {


    public MyUI(String title) throws HeadlessException {
        super(title);
        Container contentPane = getContentPane();


        JTextField text = new JTextField("文本框");


        //添加鼠标水煎
        text.addMouseListener(this);


        text.addKeyListener(this);



        contentPane.add(text);

        setSize(300,300);

        setVisible(true);

    }

    public static void main(String[] args) {
        new MyUI("测试接口");
    }




    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("MyUI.mouseClicked");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("MyUI.mousePressed");

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("MyUI.mouseReleased");

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("MyUI.mouseEntered");

    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("MyUI.mouseExited");
    }

    @Override
    public void keyTyped(KeyEvent e) {
        System.out.println("keyTyped ");
    }

    @Override
    public void keyPressed(KeyEvent e) {
        System.out.println("keyPressed ");


    }

    @Override
    public void keyReleased(KeyEvent e) {
        System.out.println("keyReleased ");


    }
}
